package com.qk.mapper;

import com.qk.entity.Activity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 活动管理Mapper接口
 */
@Mapper
public interface ActivityMapper {

    @Insert("INSERT INTO activity (channel, name, start_time, end_time, description, type, discount, voucher,create_time, update_time) " +
            "VALUES (#{channel}, #{name}, #{startTime}, #{endTime}, #{description}, #{type}, #{discount}, #{voucher},#{createTime},#{updateTime})")
    void insert(Activity activity);


    List<Activity> list(Integer channel,  Integer type, Integer status);


    @Select("SELECT id, channel, name, start_time, end_time ,description, type, discount, voucher, create_time , update_time FROM activity WHERE id = #{id}")
    Activity getActivityById(Integer id);


    int updateActivity(Activity activity);


    @Delete("DELETE FROM activity WHERE id = #{id}")
    void deleteActivity(Integer id);


    @Select("SELECT id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time FROM activity WHERE type = #{type}")
    List<Activity> selectActivitiesByType(Integer type);
}